<?php
class Default_Model_DbTable_restaurant extends Zend_Db_Table_Abstract
{
	protected $_name="hae_restaurant";
	protected $_primary="id";
	protected $_sequence=true;
	
	public function getallrestaurant($lang,$countryId,$cityId,$regionId,$spotId,$page) {
		$select = $this->select();
		$select->from($this->_name,array('id','title_'.$lang.' AS title','image','desc_'.$lang.' AS des'));
		if ($countryId!=0)
			$select->where('countryId = '.$countryId);
		if ($cityId!=0)
			$select->where('cityId = '.$cityId);
		if ($regionId!=0)
			$select->where('regionId = '.$regionId);
		if ($spotId!=0)
			$select->where('spotId LIKE  "%'.$spotId.'%"');
		$itemsPerPage = 8;
		$restaurant = new Zend_Paginator_Adapter_DbSelect($select);
		$restaurants = new Zend_Paginator($restaurant);
		$restaurants->setCurrentPageNumber($page);
		$restaurants->setItemCountPerPage($itemsPerPage);
		return $restaurants;
		
	}
}
?>